#!/bin/bash

set -x
exec 1>/var/log/$(basename $0).log 2>&1
#enable i2c interface
dtparam i2c_arm=on
modprobe i2c-dev

sleep 1

is_1a=$(i2cdetect -y  1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')



if [ "x${is_1a}" != "x" ] ; then
    echo "install wm8960-soundcard"
    dtoverlay wm8960-soundcard
    sleep 1
    
    rm /etc/asound.conf
    rm /var/lib/alsa/asound.state
    
    echo "create wm8960-soundcard configure file"
    ln -s /etc/wm8960-soundcard/asound.conf /etc/asound.conf
    
    echo "create wm8960-soundcard status file"
    ln -s /etc/wm8960-soundcard/wm8960_asound.state /var/lib/alsa/asound.state
fi

alsactl restore

#Fore 3.5mm ('headphone') jack
amixer cset numid=3 1 


